package com.tian.controller;

import com.tian.annotation.LoginCheckAnnotation;
import com.tian.common.CommonResult;
import com.tian.dto.UserBalanceChangeRespDto;
import com.tian.dto.UserBalanceDeductReqDto;
import com.tian.service.UserBalanceChangeService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * {@code @description:} 用户余额变动列表接口
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-12-07 19:20
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/api/balance")
@Api(tags = "用户余额变动列表接口")
public class UserBalanceChangeController {
    @Resource
    private UserBalanceChangeService userBalanceChangeService;

    @GetMapping("/change/list")
    @LoginCheckAnnotation
    public CommonResult<List<UserBalanceChangeRespDto>>  changeList() {
        return userBalanceChangeService.changeList();
    }
    /**
     * 扣除余额
     * @return 成功或者失败
     */
    @PostMapping("/change/deduct")
    @LoginCheckAnnotation
    public CommonResult<Boolean> deduct(@RequestBody UserBalanceDeductReqDto userBalanceDeductReqDto) {
        return userBalanceChangeService.deduct(userBalanceDeductReqDto);
    }
}
